home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 13
/
Aminet 13 - August 1996.iso
/
Aminet
/
comm
/
fido
/
MM_AStat10_GG.lha
/
MM
/
Rexx
/
MM_AreaStat.rexx
Wrap
OS/2 REXX Batch file
|
1995-09-09
|
13KB
|
672 lines
/*
** MM_AreaStat.rexx by Gabriele Greco
**
** based on AreaStat.ems by Adam Sjøgren & Bernd Ernesti
** Inspired by AreaStat.spot by Brian Jacobsen.
**
** Insert in your MailManager config file the following line:
**
** #BROWSEMENU "Statistics" "rx MM:rexx/mm_Areastat.rexx %a" "S"
**
*/
/****************************************/
/* $VER: MM_AreaStat.rexx 1.0 (25.5.95) */
/****************************************/
options results
signal on error
signal on syntax
parse arg current_area .
address MAILMANAGER
/* Variables: */
drop names.
drop fromlist.
drop tolist.
drop subjlist.
drop chars.
drop quoting.
drop subjs.
drop chars_out.
drop quoting_out.
drop from_out.
drop MM.
drop to_out.
drop subj_pit.
drop resp.
fromlist. = 0
tolist. = 0
subjlist. = 0
names.COUNT = 0
subjs.COUNT = 0
quoting.COUNT = 0
chars.COUNT = 0
to_out.COUNT = 0
from_out.COUNT = 0
subj_out.COUNT = 0
chars_out.COUNT = 0
quoting_out.COUNT = 0
m.JAN =1
m.FEB =2
m.MAR = 3
m.APR = 4
m.MAY = 5
m.JUN = 6
m.JUL = 7
m.AUG = 8
m.SEP = 9
m.OCT = 10
m.NOV = 11
m.DIC = 12
MM.PrgName = 'MM_AreaStat v1.00'
MM.Copyright = '(c) 1995 Gabriele Greco'
MM.LogLevel = 2
msgarea = current_area
MM_GetAreaInfo current_area area
if area.NMSG = 0 then
do
call Requester(MM.PrgName, 'The area 'area.NAME' is empty.', 'I knew that!' )
signal ScriptEnd
end
StartMsg = area.HIMSG - area.NMSG
EndMsg = area.HIMSG
/* A full Messagebase, or just the last month? */
res.COUNT = 4
res.0 = 'Full Messagebase'
res.1 = 'By the Real-Message-Number'
res.2 = 'By month and year'
res.3 = 'By the year'
sel. = 0
MM_SingleSelReq res sel '"How long search for ?"' NUM
if RC = 1 then signal ScriptEnd
smb = 1
month = ''
year = ''
if sel.0 = 0 then month='#?'
if sel.0 = 1 then
do
MM_StringReq '"Start Msg-Number ?"' 'StartMsg'
if StartMsg > area.HIMSG | StartMsg < (area.HIMSG - area.NMSG) then signal ScriptEnd
MM_StringReq '"End Msg-Number ?"' 'EndMsg'
if EndMsg > area.HIMSG | EndMsg < StartMsg then signal ScriptEnd
smb = 2
end
if sel.0 = 2 then
do
MM_StringReq '"Which Month (3 chars, e.g. JAN) ?"' 'month'
month = left( compress( upper( month ) ), 3 )
test = pos( month, 'JANFEBMARAPRMAYJUNJULAUGSEPOCTNOVDEC' )
if test ~= 0 & (test=1 | (test - 1)//3 = 0) then smb = 3
else month = '#?'
end
if sel.0 = 2 | sel.0 = 3 then
do
MM_StringReq '"Which Year ?"' 'year'
year = COMPRESS( year ); if year = '' | length( Year ) < 2 | DATATYPE( year ) ~= 'NUM' then
do
month = '#?'
year = '#?'
smb = 1
end
else
do
year = right( year, 2 )
if smb ~= 3 then
do
smb = 4
month = ''
end
end
end
/* A full stat's file, or just the first 10? */
res.COUNT = 2
res.0 = 'Top 10 only'
res.1 = 'Full statistics'
sel.0 = 0
MM_SingleSelReq res sel '"What kind of statistics?"' NUM
if RC = 1 then signal ScriptEnd
if sel.0 = 0 then
do
toptext = 'Top Ten'
top = 1
end
else
do
toptext = 'All'
top = 0
end
/* How do you want the output? */
output_area = ''
output_file = ''
res.COUNT=2
res.0 = 'Send as a message'
res.1 = 'To a file'
sel.0 = 0
MM_SingleSelReq res sel '"Where do you want the chart?"' NUM
if RC=1 then signal ScriptEnd
StartMsg = StartMsg + 1
if sel.0=0 then
do
res.COUNT = 2
res.0 = 'Current Area'
res.1 = 'Choose from list'
sel2. = 0
MM_SingleSelReq res sel2 '"Post in what area?"' NUM
if RC = 1 then signal ScriptEnd
if sel2.0 = 0 then
do
output_area = current_area
end
else
do
output_area = ''
MM_AreaReq 'output_area'
if RC = 1 then signal ScriptEnd
end
end
else
do
output_file = ''
MM_FileReq 'output_file'
if RC = 1 then signal ScriptEnd
end
TotalMsg = 0
firstchars = xrange('00'x,'1f'x)
lastchars = xrange('80'x,'ff'x)
do i = StartMsg to EndMsg
say 'Examining' i
MM_ReadMsg msgarea i msg
date_ = msg.DATE
to_ = msg.TO
from_ = msg.FROM
subj_ = msg.SUBJ
subj_ = upper( strip( subj_ ) )
if i = StartMsg then StartMsgDate = date_
if i = EndMsg then EndMsgDate = date_
test = pos( month || year, compress( upper( date_ ) ) )
if test = 0 & smb > 2 then iterate
if smb = 4 & (test ~= 9 & test ~= 6) then iterate
if left( subj_, 4 ) = 'RE: ' then subj_ = substr( subj_, 5 )
quotes=0
offpolicy=0
do j=0 to msg.TEXT.COUNT-1
if pos('>', msg.TEXT.j )>0 then quotes=quotes+1
else do
if verify(msg.TEXT.j,lastchars,'m')>0 then offpolicy=1
if verify(msg.TEXT.j,firstchars,'m')>0 then offpolicy=1
end
end
if quotes>0 then quotes=quotes*100/msg.TEXT.COUNT
subj_=compress(subj_,"#*')")
subj_=compress(subj_,':"?(')
from_=compress(from_,"*'")
to_=compress(to_,"*'")
MM_SearchInStem names Resp '"'from_'"' NUM
if Resp.COUNT = 0 then do
chars.from_ = 0
quoting.from_=0
MM_AddToStem 'names' 'from_'
end
MM_SearchInStem names Resp '"'to_'"' NUM
if Resp.COUNT = 0 then do
chars.to_ = 0
quoting.to_=0
MM_AddToStem 'names' 'to_'
end
MM_SearchInStem subjs Resp '"'subj_'"' NUM
if Resp.COUNT = 0 then do
MM_AddToStem 'subjs' 'subj_'
end
if (fromlist.from_>0) then quoting.from_ = (quoting.from_*fromlist.from_+quotes)/(fromlist.from_+1)
else quoting.from_ = quotes
say 'from:' from_ 'quoting:' quotes||'% offpolicy:' offpolicy 'subj:' subj_
if offpolicy=1 then chars.from_ = chars.from_ + 1
tolist.to_ = tolist.to_ + 1
fromlist.from_ = fromlist.from_ + 1
subjlist.subj_ = subjlist.subj_ + 1
TotalMsg = TotalMsg + 1
end
if month="#?" then do
say StartMsgDate
parse var StartMsgDate giorno ' ' mese ' ' anno ' '
mese = UPPER(mese)
ms = copies( '0', 2-length(m.mese))||m.mese
a='19'||anno||ms||giorno
say a
sd = date('I',a,'S')
say EndMsgDate
parse var EndMsgDate giorno ' ' mese ' ' anno ' '
mese = UPPER(mese)
ms = copies( '0', 2-length(m.mese))||m.mese
a='19'||anno||ms||giorno
say a
ed = date('I',a,'S')
days = ed - sd
end
else days=30
messgiorno = TotalMsg / days
messgiorno = messgiorno % 1
do i=0 to names.COUNT-1
say names.i
end
do i=0 to subjs.COUNT-1
say subjs.i
end
if TotalMsg = 0 then
do
call Requester(MM.PrgName, 'No messages found !', 'Bye!')
signal ScriptEnd
end
/* Make the TO: stem ready */
do i = 0 to names.COUNT-1
aname = names.i
if tolist.aname > 0 then
do
percent = tolist.aname * 100 / TotalMsg
remainder = percent // 1
percent = percent % 1
if remainder > 0.5 then percent = percent + 1
out_1 = copies( ' ', (length( names.COUNT ) + 1) - length( tolist.aname ) ) || tolist.aname
out_2 = 'msgs(' || copies( ' ', 3 - length( percent ) ) || percent || '%) to' aname
out=out_1||' '||out_2
MM_AddToStem to_out 'out'
end
end
MM_SortStem to_out
/* Make the offpolicy chars stem ready */
do i = 0 to names.COUNT-1
aname = names.i
if chars.aname > 0 then
do
out_1 = copies( ' ', (length( names.COUNT ) + 1) - length( chars.aname ) ) || chars.aname
out_2 = 'msgs with off-policy characters by' aname
out=out_1||' '||out_2
MM_AddToStem chars_out 'out'
end
end
MM_SortStem chars_out
/* The FROM: stem: */
do i = 0 to names.COUNT-1
aname = names.i
if fromlist.aname > 0 then
do
percent = fromlist.aname * 100 / TotalMsg
remainder = percent // 1
percent = percent % 1
if remainder > 0.5 then percent = percent + 1
out_1 = copies( ' ', (length( names.COUNT ) + 1) - length( fromlist.aname ) ) || fromlist.aname
out_2 = 'msgs(' || copies( ' ', 3 - length( percent ) ) || percent || '%) from' names.i
out=out_1||' '|| out_2
MM_AddToStem from_out 'out'
end
end
MM_SortStem from_out
/* The quoting stem: */
do i = 0 to names.COUNT-1
aname = names.i
if quoting.aname > 0 then
do
remainder = quoting.aname // 1
percent = quoting.aname % 1
if remainder > 0.5 then percent = percent + 1
out = copies( ' ', 3 - length( percent ) ) || percent || '% of quoting ('||copies( ' ',(length( names.COUNT ) + 1) - length( fromlist.aname )) || fromlist.aname || ' msgs) by' names.i
MM_AddToStem quoting_out 'out'
end
end
MM_SortStem quoting_out
/* The SUBJ: stem: */
do i = 0 to subjs.COUNT-1
subj_ = subjs.i
if subjlist.subj_ > 0 then
do
percent = subjlist.subj_ * 100 / TotalMsg
remainder = percent // 1
percent = percent % 1
if remainder > 0.5 then percent = percent + 1
out_1 = copies( ' ', (length( subjs.COUNT ) + 1) - length( subjlist.subj_ ) ) || subjlist.subj_
out_2 = 'topics(' || copies( ' ', 3 - length( percent ) ) || percent || '%) :' subjs.i
out=out_1||' '||out_2
MM_AddToStem subj_out 'out'
end
end
MM_SortStem subj_out
/* Do the output: */
temp_file = 't:MM_areastat'
mline = '----------------------------------------------------------------------------'
call open( 'temp', temp_file, 'W' )
call writeln( 'temp', '' )
call writeln( 'temp', 'Area-Statistics for' msgarea )
call writeln( 'temp', 'Generated with the MailManager Statistic Generator')
call writeln( 'temp', 'written by Gabriele Greco')
call writeln( 'temp', mline )
if smb = 1 then call writeln( 'temp', 'Full Messagebase with' TotalMsg 'messages')
if smb = 2 then call writeln( 'temp', 'Msg #' || StartMsg '(' || StartMsgDate || ')' '-' '#' || EndMsg '(' || EndMsgDate || ')' 'with' TotalMsg 'msgs')
if smb > 2 then
do
if smb = 3 then part = 'Month' month
else part = 'Year'
if year > 77 then part = part '19' || year
else part = part '20' || year
call writeln( 'temp', 'Messagebase from' part 'with' TotalMsg 'messages' )
end
call writeln( 'temp', 'Statistics generated on :' DATE() 'at' TIME() )
call writeln( 'temp', 'Active users in this area:' names.COUNT )
call writeln( 'temp', 'Average messages/day :' messgiorno )
call writeln( 'temp', mline )
call writeln( 'temp', '' )
if top = 1 then
do
low_f = (from_out.COUNT) - 10; j_f = 10
low_t = ( to_out.COUNT) - 10; j_t = 10
low_s = (subj_out.COUNT) - 10; j_s = 10
j_q = 10
if quoting_out.COUNT>10 then low_q = (quoting_out.COUNT) - 10
else do
low_q=0
j_q=quoting_out.COUNT
end
j_o=10
if chars_out.COUNT>10 then low_o = (chars_out.COUNT) - 10
else do
low_o=0
j_o= chars_out.COUNT
end
end
else
do
low_f = 0; j_f = from_out.COUNT
low_t = 0; j_t = to_out.COUNT
low_s = 0; j_s = subj_out.COUNT
low_q = 0; j_q = quoting_out.COUNT
low_o = 0; j_o = quoting_out.COUNT
end
j = 0
call writeln( 'temp', toptext 'Submitters:' )
call writeln( 'temp', mline )
do i = (from_out.COUNT-1) to 0 by -1
if i < low_f then leave
j = j + 1
call writeln( 'temp', copies( ' ', length( j_f ) - length( j ) ) || j || '. ' || from_out.i )
end
call writeln( 'temp', '' )
j = 0
call writeln( 'temp', toptext 'Recipiants:' )
call writeln( 'temp', mline )
do i = (to_out.COUNT - 1 ) to 0 by -1
if i < low_t then leave
j = j + 1
call writeln( 'temp', copies( ' ', length( j_t ) - length( j ) ) || j || '. ' || to_out.i )
end
call writeln( 'temp', '' )
j = 0
call writeln( 'temp', toptext 'Topics:' )
call writeln( 'temp', mline )
do i = (subj_out.COUNT - 1) to 0 by -1
if i < low_s then leave
j = j + 1
call writeln( 'temp', copies( ' ', length( j_s ) - length( j ) ) || j || '. ' || subj_out.i )
end
call writeln( 'temp', '' )
j = 0
call writeln( 'temp', toptext 'Quoters:' )
call writeln( 'temp', mline )
do i = (quoting_out.COUNT - 1) to 0 by -1
if i < low_q then leave
j = j + 1
call writeln( 'temp', copies( ' ', length( j_q ) - length( j ) ) || j || '. ' || quoting_out.i )
end
call writeln( 'temp', '' )
j = 0
if chars_out.COUNT>0 then do
call writeln( 'temp', toptext 'writers of off-policy characters:' )
call writeln( 'temp', mline )
do i = (chars_out.COUNT - 1) to 0 by -1
if i < low_o then leave
j = j + 1
call writeln( 'temp', copies( ' ', length( j_o ) - length( j ) ) || j || '. ' || chars_out.i )
end
call writeln( 'temp', '' )
end
call close( 'temp' )
if output_file ~= '' then address command 'copy' temp_file '"'output_file'"'
if output_area ~= '' then
do
MM_GetSysop sysop
sysop = sysop||'''s Statistics'
origine = ' Mail Manager statistics of '||area.NAME
mess.FROM = sysop
mess.FROMADDR = area.ADDR
mess.TO = 'All'
mess.SUBJ = 'Stats for this area'
mess.TEAR = 'GG AreaStat'
mess.ORIGIN = origine
if exists( temp_file ) then mess.FILE = temp_file
MM_WriteMsg output_area 'mess'
end
address command 'Delete >NIL:' temp_file
ScriptEnd:
exit 0
error:
syntax:
if rc>0 then error_text = errortext(rc)
say '** GG AreaStat: error at' rc sigl error_text
exit rc
Requester: PROCEDURE EXPOSE MM.
PARSE ARG Titolo, Testo, GadGets
MM_Requester '"'Titolo'"' 'Testo' 'GadGets'
RETURN